<?
	$rootPath =  realpath(dirname(__FILE__).'/../').'/';
	include($rootPath.'includes/loader.php');


	$options = getopt("d:");
	$WHERE = array();
	if ($options['d'] == "odd") {
		$WHERE[] = "MOD(id,2) = 1";
	} elseif ($options['d'] == "even") {
		$WHERE[] = "MOD(id,2) = 0";
	} elseif($options['d'] == 'all') {
	} elseif($options['d']) {
		$WHERE[] = "id='".$options['d']."'";
	}

	if(empty($options)) {
		echo("-d <device id>                Poll single device\n");
		echo("-d odd                        Poll odd numbered devices  (same as -i 2 -n 0)\n");
		echo("-d even                       Poll even numbered devices (same as -i 2 -n 1)\n");
		echo("-d all                        Poll all devices\n\n");
		echo("\n");
		echo("No Device ID specified!\n");
		exit;
	}

	$sql = 	"SELECT id ".
			"FROM devices ";
	if (!empty($WHERE)) {
		$sql .= "WHERE ".implode(' AND ',$WHERE)." ";
	}
	foreach ($nms->db->getObjects($sql) AS $d) {
		$device = new objDevice($d->id);	
		echo 'Ping Response:'.$device->ping().chr(10);
	}

?>